<template>
    <div class="resultlist" >
        <ul>
            <li v-for="(item ,index) in list" :key="index">
                <line-item :type="params.search_type" :item='item'></line-item>
            </li>
        </ul>
    </div>
</template>

<script>
import LineItem from '../../components/common/LineItem.vue'
export default {
    components:{
        LineItem
    },
    props:[
        'params'
    ],
    data(){
        return{
            list:[],
            page:1
        }
    },
    methods:{
        scroll(){
            let offsetHeight= document.scrollingElement.offsetHeight
            let scrollTop= parseInt(document.scrollingElement.scrollTop)
            let screen=window.screen.height
            if((offsetHeight==scrollTop+screen)||(offsetHeight==scrollTop+screen+1)){
                this.getresult(this.page++)
            }
        },
        getresult(page){
            let url='/static/x/web-interface/search/type'
            let params=this.params
            params.page=page
            console.log(this.params)
            this.$axios.get(url,{params}).then(res=>{
                this.list.push(...res.data.data.result)
                console.log(res.data.data.result)
            })
        }
    },
    activated(){
        window.addEventListener('scroll',this.scroll)

    },
    deactivated(){
        window.removeEventListener('scroll',this.scroll)
    },
    created(){
        this.getresult(this.page++)
    }

}
</script>

<style>

</style>